@extends('admin.common.main')
<style>
    .checkbox1 {
        width: 16px;
        height: 16px;
        margin: 0 5px 0 10px !important;
    }
</style>
@section('cnt')
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span> 角色管理
        <span class="c-gray en">&gt;</span> 角色授予权限
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
           href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>


    <article class="page-container">
        {{--引用验证--}}
        @include('admin.common.validate')
        @include('admin.common.msg')

        <input class="checkbox1" id="selectAll" type="checkbox" name="" value="">全选
        <form action="{{route('admin.role.authSave',$role)}}" method="post" class="form form-horizontal" id="form-role-add">
            @csrf
            @foreach($authAll as $v)
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <input class="checkbox1" data-id="{{$v['id']}}" type="checkbox"
                               @if(in_array($v['id'],$auth)) checked @endif name="auth[]" value="{{$v['id']}}">
                        {{$v['auth_name']}}
                    </div>
                    @foreach($v['son'] as $vv)
                        <div class="panel-body">
                            <input class="checkbox1" id="{{$vv['id']}}" data-id="{{$vv['pid']}}" type="checkbox"
                                   @if(in_array($vv['id'],$auth)) checked @endif name="auth[]" value="{{$vv['id']}}">{{$vv['auth_name']}}
                        </div>
                        <div style=" margin: 0px 0px 20px 20px; padding: 20px;border: 1px solid #ddd">
                            @foreach($vv['son'] as $vvv)
                                <input class="checkbox1" type="checkbox" @if(in_array($vvv['id'],$auth)) checked
                                       @endif data-id="{{$vvv['pid']}}" name="auth[]" value="{{$vvv['id']}}">{{$vvv['auth_name']}}
                            @endforeach
                        </div>
                    @endforeach
                </div>
            @endforeach

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
@endsection

@section('js')
    <script type="text/javascript" src="{{env('APP_URL')}}admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="{{env('APP_URL')}}admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="{{env('APP_URL')}}admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script>
        $('#selectAll').click(function () {
            if (this.checked) {
                $(".checkbox1").prop("checked", true);
            } else {
                $(".checkbox1").prop("checked", false);
            }
        });
    </script>
@endsection
